package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping(path = "/nursingLevel")
@Api(tags = "护理等级管理")
public class NursingLevelController {
    private final NursingLevelService nursingLevelService;

    /**
     * 查询所有护理等级
     */
    @ApiOperation(value = "查询所有护理等级")
    @GetMapping(path = "/listAll")
    public ResponseResult<List<NursingLevelVo>> findNursingLevelList() {
        List<NursingLevelVo> list=nursingLevelService.findNursingLevelList();
        return ResponseResult.success(list);
    }

    /**
     * 新增护理等级
     */
    @ApiOperation(value = "新增护理等级")
    @PostMapping(path = "/insert")
    public ResponseResult<Void> insertNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.insertNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

    /**
     * 分页查询
     */
    @ApiOperation(value = "分页查询")
    @GetMapping(path = "/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> queryNursingLevel(String name,Integer pageNum, Integer pageSize, Integer status){
        PageResponse<NursingLevelVo> pageResponse= nursingLevelService.queryNursingLevel(name,pageNum,pageSize,status);
        return ResponseResult.success(pageResponse);
    }

    /**
     * 根据id查询
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping(path = "/{id}")
    public ResponseResult<NursingLevelVo> findNursingLevelById(@PathVariable Integer id){
        NursingLevelVo nursingLevelVo = nursingLevelService.findNursingLevelById(id);
        return ResponseResult.success(nursingLevelVo);
    }

    /**
     * 修改护理等级
     */
    @ApiOperation(value = "修改护理等级")
    @PutMapping(path = "/update")
    public ResponseResult<Void> modifyNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.modifyNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

    /**
     * 删除护理等级
     */
    @ApiOperation(value = "删除护理等级")
    @DeleteMapping(path = "/delete/{id}")
    public ResponseResult<Void>  deleteNursingLevel(@PathVariable Integer id){
        nursingLevelService.deleteNursingLevel(id);
        return ResponseResult.success();
    }

    /**
     * 启用/禁用
     */
    @ApiOperation(value = "启用/禁用")
    @PutMapping(path = "/{id}/status/{status}")
    public ResponseResult<Void>  modifyNursingLevelStatus(@PathVariable("id") Integer id,@PathVariable("status") Integer status){
        nursingLevelService.modifyNursingLevelStatus(id,status);
        return ResponseResult.success();
    }
}
